export const isObstruction = function (element: HTMLTextAreaElement) {
    if (!element) return false;
    try {
        const rect = element.getBoundingClientRect();
        const viewportHeight = window.innerHeight || document.documentElement.clientHeight;
        // 元素完全在视口外的情况
        if (rect.bottom < 0 || rect.top > viewportHeight) {
            return true;
        }
        // 计算遮挡比例
        const visibleHeight = Math.min(rect.bottom, viewportHeight) - Math.max(rect.top, 0);
        const obstructionRatio = 1 - visibleHeight / rect.height;

        // 超过30%被遮挡则判定为被遮挡
        return obstructionRatio > 0.3;
    } catch (error) {
        console.error('遮挡检测出错:', error);
        return false;
    }
};
